/*
 * 文件名称: AdminService.java
 * 版权信息: Copyright 2005-2013 SKY-MOBI Inc. All right reserved.
 * ----------------------------------------------------------------------------------------------
 * 修改历史:
 * ----------------------------------------------------------------------------------------------
 * 修改原因: 新增
 * 修改人员: Allen.Hu
 * 修改日期: 2013-3-30
 * 修改内容: 
 */
package com.drzui.tickets.order.service;

import java.util.List;

import org.bigmouth.framework.dao.generator.Service;

import com.drzui.tickets.order.dao.OrdersGoodsinfoDao;
import com.drzui.tickets.order.entity.OrdersGoodsinfo;
import com.drzui.tickets.order.entity.OrdersGoodsinfoCondition;
import com.drzui.tickets.order.entity.OrdersGoodsinfoCondition.Criteria;

public class OrdersGoodsinfoService extends
		Service<OrdersGoodsinfo, OrdersGoodsinfoCondition, Integer, OrdersGoodsinfoDao> {
	
	private OrdersGoodsinfoDao OrdersGoodsinfoDao;
	
	/**
	 * 根据订单号获取订单商品信息
	 * @param OrdersGoodsinfo 查询条件
	 * @return 结果集
	 */
	public List<OrdersGoodsinfo> getOrdersGoodsinfo(OrdersGoodsinfo OrdersGoodsinfo){
		OrdersGoodsinfoCondition condition = new OrdersGoodsinfoCondition();
		Criteria criteria = condition.createCriteria();
		criteria.andOrderidEqualTo(OrdersGoodsinfo.getOrderid());
		condition.setOrderByClause("goodsid ASC");
		List<OrdersGoodsinfo> rs = OrdersGoodsinfoDao.selectByCondition(condition);
		
		if (rs != null && rs.size() > 0) {
			return rs;
		}
		return null;
	}
	
	/**
	 * 根据商品id获取商品信息
	 * @param goodsid 商品id
	 * @return 对象
	 */
	public OrdersGoodsinfo getGoodsinfo(String goodsid){
		OrdersGoodsinfoCondition condition = new OrdersGoodsinfoCondition();
		Criteria criteria = condition.createCriteria();
		criteria.andGoodsidEqualTo(goodsid.toString());
		List<OrdersGoodsinfo> rs = OrdersGoodsinfoDao.selectByCondition(condition);
		
		if (rs != null && rs.size() > 0) {
			return rs.get(0);
		}
		return null;
	}
	
	/**
	 * 新增订单商品信息
	 * @param goodsList 商品信息集合
	 */
	public void newGoodsList(List<OrdersGoodsinfo> goodsList) {
		for (int i = 0; i < goodsList.size(); i++) {
			OrdersGoodsinfoDao.insert(goodsList.get(i));
		}
	}
	
	/**
	 * 修改订单商品信息
	 * @param goodsList 商品信息集合
	 */
	public void modifyGoodsList(List<OrdersGoodsinfo> goodsList) {
		for (int i = 0; i < goodsList.size(); i++) {
			OrdersGoodsinfoDao.updateByPrimaryKey(goodsList.get(i));
		}
	}
	
	/**
	 * 删除订单商品信息
	 * @param goodsList 商品信息集合
	 */
	public void removeGoodsList(List<OrdersGoodsinfo> goodsList) {
		for (int i = 0; i < goodsList.size(); i++) {
			OrdersGoodsinfoDao.deleteByPrimaryKey(goodsList.get(i).getId());
		}
	}
	
	@Override
	protected OrdersGoodsinfoDao getDao() {
		return OrdersGoodsinfoDao;
	}

	public OrdersGoodsinfoDao getOrdersGoodsinfoDao() {
		return OrdersGoodsinfoDao;
	}

	public void setOrdersGoodsinfoDao(OrdersGoodsinfoDao OrdersGoodsinfoDao) {
		this.OrdersGoodsinfoDao = OrdersGoodsinfoDao;
	}

	
}
